package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

/**
 * 枚举值的大小很重要，getProgressNum()的大小代表小车任务的执行进度
 *
 * @author Administrator
 */
public enum TaskRgvProgress implements IBaseEnum<Serializable> {
    /**
     * 任务等待分配车辆
     */
    NOT_ASSIGNED_TO_RGV(0, "等待分配车辆"),
    /**
     * 预分车
     */
    PREASSIGN(10, "预分车"),
    /**
     * 任务已分配给小车
     */
    ASSIGNED_TO_RGV(20, "已分配车辆"),
    /**
     * 小车开始执行
     */
    RGV_TO_RUN(30, "车辆开始执行"),
    /**
     * 小车前往起点中
     */
    RGV_TO_START(31, "前往起点中"),
    /**
     * 取货中
     */

//    TAKE_PALLET_ING(31, "取货中"),

    /**
     * 小车前往终点中
     */
    RGV_TO_END(59, "前往终点中"),

    /**
     * 四向车移库到提升机接驳点
     */
    RGV_RUN_TO_OUT_LIFTER(33,"移库接驳点"),

    /**
     * 四向车进入提升机
     */
    RGV_INTO_LIFTER(34,"进入提升机"),

    /**
     * 两向车移货
     */
    RGV2_MOVE_CARGO(35,"两向车移货"),

    /**
     * 四向车离开提升机
     */
    RGV_LEAVE_LIFTER(36,"离开提升机"),



    /**
     * 放货中
     */
//    PUT_PALLET_ING(32, "放货中"),
    RGV_SON_OUT_TO_GET(40, "子车前往取货点"),
    RGV_GET_CARGO(41, "子车取货完成"),
    RGV_SON_LEAVE_GET(42, "子车离开取货点"),
    RGV_SON_OUT_TO_PUT(60, "子车前往放货点"),
    RGV_PUT_CARGO(61, "子车放货完成"),
    RGV_SON_LEAVE_PUT(62, "子车离开放货点"),
    RGV_SON_GOTO_TARGET(70, "子车前往目标点"),
    /**
     * 小车任务完成
     */
    RGV_COMPLETE(100, "车辆调度完成");
    @EnumValue
    private int taskProgress;
    @JsonValue
    private String description;

    TaskRgvProgress(int taskProgress, String description) {
        this.taskProgress = taskProgress;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static TaskRgvProgress parseTaskProgress(int taskProgress) {
        TaskRgvProgress[] taskDeviceProgresses = TaskRgvProgress.values();
        for (TaskRgvProgress progress : taskDeviceProgresses) {
            if (progress.taskProgress == taskProgress) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度参数异常" + taskProgress);
    }

    public static TaskRgvProgress getByTaskProgress(int taskProgress) {
        TaskRgvProgress[] taskDeviceProgresses = TaskRgvProgress.values();
        for (TaskRgvProgress progress : taskDeviceProgresses) {
            if (progress.taskProgress == taskProgress) {
                return progress;
            }
        }
        throw null;
    }

    public static TaskRgvProgress parseTaskProgress(String description) {
        TaskRgvProgress[] taskDeviceProgresses = TaskRgvProgress.values();
        for (TaskRgvProgress progress : taskDeviceProgresses) {
            if (progress.description.equals(description)) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度描述异常" + description);
    }

    public int getProgressNum() {
        return taskProgress;
    }

    @Override
    public Serializable getValue() {
        return taskProgress;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return taskProgress;
    }
}
